package com.hand.wfive.adapter;

import android.graphics.Paint;
import android.text.TextUtils;
import android.widget.TextView;

import com.hand.wfive.R;
import com.hand.wfive.loginAndVip.model.VipGoodsModel;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;

public class VipPriceConfigAdapter extends BaseCheckPositionAdapter<VipGoodsModel, BaseViewHolder> {

    public VipPriceConfigAdapter() {
        super(R.layout.item_price_vip_center);
        baseCheckPosition = 0;
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, VipGoodsModel item) {

        holder.setVisible(R.id.tvDiscountDesc, !TextUtils.isEmpty(item.getPaperWork()));
        holder.setText(R.id.tvDiscountDesc, item.getPaperWork());

        holder.setText(R.id.tvVipName, item.getAccName());
        holder.setText(R.id.tvVipPrice, item.getProductPrice());
        if (!TextUtils.isEmpty(item.getProductOriginalPrice())) {
            holder.setText(R.id.tvOriginalPrice, "¥" + item.getProductOriginalPrice());
            TextView tvOriginalPrice = holder.getView(R.id.tvOriginalPrice);
            tvOriginalPrice.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG);
        } else {
            holder.setText(R.id.tvOriginalPrice, "");
        }

        boolean isSelect = baseCheckPosition == getItemPosition(item);
        holder.getView(R.id.vipLayout).setSelected(isSelect);
        holder.getView(R.id.tvVipName).setSelected(isSelect);
        holder.getView(R.id.tvVipPriceUnit).setSelected(isSelect);
        holder.getView(R.id.tvVipPrice).setSelected(isSelect);
    }
}
